package com.suning.sawp.dto.storeman;

public class JsonResult {
	
	public  static final String SUCCESS_FLAG = "1";

	public  static final String ERROR_FLAG = "0";

	private String retFlag;
	private String errorCode;
	private String errorMessage;
	private String exceptionMsg;
	private Object data;

	public JsonResult(String retFlag, String errorCode, String errorMessage,
			Object data) {
		this.retFlag = retFlag;
		this.errorCode = errorCode;
		this.errorMessage = errorMessage;
		this.data = data;

	}
	
	public JsonResult() {

	}

	public JsonResult(Object data) {
		this.retFlag = SUCCESS_FLAG;
		this.data = data;
	}

	public JsonResult(String errorCode, String errorMessage) {

		this.retFlag = ERROR_FLAG;
		this.errorCode = errorCode;
		this.errorMessage = errorMessage;

	}

	public JsonResult(String errorCode, String errorMessage,
			Throwable th) {
		this.retFlag = ERROR_FLAG;
		this.errorCode = errorCode;
		this.errorMessage = errorMessage;
		this.exceptionMsg = String.format("%s %s",
				th.getClass().getSimpleName(), null == th.getMessage() ? ""
						: th.getMessage());
	}

	public String getExceptionMsg() {
		return exceptionMsg;
	}

	public void setExceptionMsg(String exceptionMsg) {
		this.exceptionMsg = exceptionMsg;
	}

	public String getRetFlag() {
		return retFlag;
	}

	public void setRetFlag(String retFlag) {
		this.retFlag = retFlag;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

}
